﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using Newtonsoft.Json.Linq;

using CanDoo;
using CanDoo.Core;
using CanDoo.Data;
using CanDoo.Web;
using CanDoo.FineUI;
using CanDoo.Extensions;
using CanDoo.Core.Context;
using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.DTOs;
using CanDoo.Oil.Core.Contracts;
using CanDoo.Admin.Core.Contracts;
using FineUIPro;

namespace CanDoo.Oil.WebApp.sellOutStore
{
    public partial class Print : PageBase
    {
        public IOutStoreContract OutStoreContract { get; set; }
        public IOutStoreDetailContract OutStoreDetailContract { get; set; }
        public IProductUnitContract ProductUnitContract { get; set; }
        public long Id = Web.Request.QueryString("Id").ToLong();
        public OutStore entity;
        public List<OutStoreDetail> entityDetails;
        public List<ProductUnit> productUnits;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Id == 0L)
            {
                Response.Clear();
                Response.Write("参数错误");
                Response.End();
            }
            else
            {
                DB.KeepReading(() =>
                {
                    entity = OutStoreContract.GetIncludes(new string[] { "User", "Customer", "Warehouse" }).FirstOrDefault(p => p.Id == Id);
                    if (entity == null)
                    {
                        Response.Clear();
                        Response.Write("未找到相关记录");
                        Response.End();
                    }

                    entityDetails = OutStoreDetailContract.GetInclude(p => p.Product).ToList();
                    productUnits = ProductUnitContract.Entities.ToList();
                });
            }
        }
    }
}